﻿@using System.Text.RegularExpressions
@using Common
@using Masuit.Tools.Net
@using Masuit.Tools.Win32
@using Models.Entity
@model PostHistoryVersion
@{
    ViewBag.Title = Model.Post.Title+"于"+Model.ModifyDate.ToString("yyyy-MM-dd HH:mm:ss")+"的历史版本："+Model.Title;
    Layout = "~/Views/Shared/_Layout.cshtml";
    string[] colors = { "success", "info", "primary", "warning", "danger", "default", "primary" };
}
<link href="~/Assets/jquery.tocify/jquery.tocify.min.css" rel="stylesheet" />
<link href="~/Assets/UEditor/third-party/SyntaxHighlighter/styles/shCore.min.css" rel="stylesheet" />
<div class="container">
    <ol class="cd-breadcrumb triangle">
        <li>@Html.ActionLink("首页", "Index", "Home")</li>
        <li>@Html.ActionLink("文章列表", "Post", "Home")</li>
        <li>@Html.ActionLink(Model.Post.Title.Length>20?Model.Post.Title.Substring(0,20)+"...": Model.Post.Title, "Details", "Post",new{id=Model.PostId},null)</li>
        <li>@Html.ActionLink("历史版本", "History", "Post",new{id=Model.PostId},null)</li>
        <li class="current"><em>@(Model.Title.Length>40? Model.Title.Substring(0,40)+"...": Model.Title)</em></li>
    </ol>
    <div class="wrapper-content article">
        <div class="ibox">
            <div class="ibox-content animated fadeIn">
                <main>
                    <section>
                        <header class="page-header">
                            <div class="text-center">
                                <a>
                                    <h2 class="padding-bot10">
                                        @Model.Title
                                    </h2>
                                </a>
                            </div>
                            <div class="row">
                                <div class="col-sm-7">
                                    <div class="padding-bot10">
                                        修改于<span class="text-success">@Model.ModifyDate.ToString("yyyy-MM-dd HH:mm:ss")</span> | 
                                    原分类：<i class="icon-map-pin"></i>@Html.ActionLink(Model.Category.Name, "Category", "Home", new { id = Model.CategoryId }, new { @class = "label label-" + colors[new Random().StrictNext() % colors.Length] })
                                    @if (Model.Seminar.Any())
                                    {
                                        <span> | 原所属专题：</span>
                                        var seminars = Model.Seminar;
                                        foreach (Seminar s in seminars)
                                        {
                                            @Html.ActionLink(s.Title, "Index", "Seminar", new { id = s.Id }, new { @class = "label label-" + colors[new Random().StrictNext() % colors.Length] })<text> </text>
                                        }
                                    }
                                        <button class="btn btn-danger btn-sm" id="del">删除此版本</button>
                                    </div>
                                </div>
                                @{
                                    if (!string.IsNullOrEmpty(Model.Label))
                                    {
                                        <div class="pull-right margin-right20">
                                            <div>
                                                @foreach (string s in Model.Label.Split(',', '，', ' '))
                                                {
                                                    if (!string.IsNullOrEmpty(s))
                                                    {
                                                        <a href="/tag/@Server.UrlEncode(s)">
                                                            <span class="label label-@colors[new Random().StrictNext() % colors.Length]">@s</span>
                                                        </a>
                                                    }
                                                }
                                            </div>
                                        </div>
                                    }
                                }
                            </div>
                        </header>
                        <article class="article" id="article">
                            @MvcHtmlString.Create(Model.Content)
                            @if(!string.IsNullOrEmpty(Model.ProtectContent)) {
                            <div class="row protected">
                                @MvcHtmlString.Create(Model.ProtectContent)
                            </div>
                            }
                        </article>
                        <div id="cyReward" role="cylabs" data-use="reward"></div>
                    </section>
                </main>
                <hr />
                <section class="wow fadeInUp row size16">
                    <div class="col-xs-6">
                        前一版本：
                        @{
                            PostHistoryVersion prev = ViewBag.Prev;
                            if (prev != null)
                            {
                                @Html.ActionLink(prev.Title, "HistoryVersion", "Post", new { id = prev.PostId, hid = prev.Id }, null)
                            }
                            else
                            {
                                <a>没有了</a>
                            }
                        }
                    </div>
                    <div class="col-xs-6 text-right">
                        下一版本：
                        @{
                            PostHistoryVersion next = ViewBag.Next;
                            if (next != null)
                            {
                                @Html.ActionLink(next.Title, "HistoryVersion", "Post", new { id=next.PostId,hid = next.Id }, null)
                            }
                            else
                            {
                                <a>没有了</a>
                            }
                        }
                    </div>
                </section>
                <!--PC和WAP自适应版-->
                <div id="SOHUCS" sid="history-@Model.Id"></div>
                <script type="text/javascript">
	                (function() {
		                var appid = 'cytsT3QgK';
		                var conf = 'prod_0358240040a6c9611add9de991099d42';
		                var width = window.innerWidth || document.documentElement.clientWidth;
		                if (width < 960) {
			                window.document.write(
				                '<script id="changyan_mobile_js" charset="utf-8" type="text/javascript" src="https://changyan.sohu.com/upload/mobile/wap-js/changyan_mobile.js?client_id=' +
				                appid + '&conf=' + conf + '"><\/script>');
		                } else {
			                var loadJs = function(d, a) {
				                var c = document.getElementsByTagName("head")[0] || document.head || document.documentElement;
				                var b = document.createElement("script");
				                b.setAttribute("type", "text/javascript");
				                b.setAttribute("charset", "UTF-8");
				                b.setAttribute("src", d);
				                if (typeof a === "function") {
					                if (window.attachEvent) {
						                b.onreadystatechange = function() {
							                var e = b.readyState;
							                if (e === "loaded" || e === "complete") {
								                b.onreadystatechange = null;
								                a()
							                }
						                }
					                } else {
						                b.onload = a
					                }
				                }
				                c.appendChild(b)
			                };
			                loadJs("https://changyan.sohu.com/upload/changyan.js", function() {
				                window.changyan.api.config({
					                appid: appid,
					                conf: conf
				                })
			                });
		                }
	                })();
                </script>
            </div>
        </div>
    </div>
</div>
<script src="~/Assets/UEditor/third-party/SyntaxHighlighter/scripts/shCore.min.js"></script>
<script src="~/Assets/UEditor/third-party/SyntaxHighlighter/scripts/bundle.min.js"></script>
<script src="~/Assets/jquery.tocify/jquery.tocify.js"></script>
<script>
    $(function() {
		$("#toc").show();
        var toc = $("#toc").tocify({
            selectors: ".ibox-content h3,.ibox-content h4,.ibox-content h5"
        }).data("toc-tocify");
	    $(".tocify>.close").on("click", function(e) {
		    $(this).parent().hide();
	    });		
	    SyntaxHighlighter.all();
	    SyntaxHighlighter.defaults['toolbar'] = false;
        $("#del").on("click", function (e) {
            swal({
                title: "确认删除这个版本吗？",
                text: '@Model.Title',
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                showLoaderOnConfirm: true,
                animation: true,
                allowOutsideClick: false
            }).then(function () {
                $.post("/post/DeleteHistory", {
                    id: @Model.Id
                }, function (data) {
                    window.notie.alert({
                        type: 1,
                        text: data.Message,
                        time: 4
                    });
                    location.href="/@Model.PostId/history";
                });
            }, function () {
            });
        });
	})
</script>